package com.open.recruitment.recruit.controller;

import com.open.capacity.common.exception.controller.ControllerException;
import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.common.model.CompanyActive;
import com.open.capacity.common.model.SysRecruit;
import com.open.capacity.common.model.SysUser;
import com.open.capacity.common.util.PageUtil;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.common.web.Result;
import com.open.capacity.log.annotation.LogAnnotation;
import com.open.recruitment.recruit.service.RecruitService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/recruit")
public class RecruitInformationController {
    @Autowired
    private RecruitService recruitService;
//添加招聘信息
    @PostMapping("/addRecruitInformation")
    public Result addRecruitInformation(@RequestBody SysRecruit sysRecruit){
        return recruitService.addRecruitInformation(sysRecruit);
    }

    //招聘信息更新
    @PostMapping("/updateRecruitInformation")
    public Result updateRecruitInformation(@RequestBody SysRecruit sysRecruit){
        return recruitService.updateRecruitInformation(sysRecruit);
    }
//招聘信息删除
    @PostMapping("/deleteRecruitInformation/{id}")
    public Result deleteRecruitInformation(@PathVariable Long id){
        return  recruitService.deleteRecruitInformation(id);
    }
////    模糊查询
//    @PostMapping("/selectAll")
//    public PageResult selectAll(@RequestParam Map<String,Object> map) {
//        List<SysRecruit> list = new ArrayList<>();
//        PageUtil.pageParamConver(map,true);
//        list = recruitService.selectAll(map);
//        return PageResult.<SysRecruit>builder().code(0).
//        data(list).count((long)list.size()).build();
//    }
    // 查询招聘信息与公司关联
    @PostMapping("/selectCompanyName")
    public PageResult selectCompanyName(@RequestParam Map<String,Object> map){
        List<SysRecruit> list = new ArrayList<>();
        PageUtil.pageParamConver(map,true);
        list = recruitService.selectCompanyName(map);
        return PageResult.<SysRecruit>builder().code(0).
        data(list).count((long)list.size()).build();
    }

}
